package com.mypro.mapper;

import com.mypro.entity.Dept;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * @author user_xdd
 * @Date 2022-05-18 22:28
 * @description
 * @return
 */
public interface DeptMapper {
    @Select("select * from dept")
    @Results(id = "deptMap",value = {
        @Result(id = true ,column = "deptno",property = "deptno",javaType =Integer.class ),
            @Result(column = "deptno",property = "empList",javaType = List.class ,
                many = @Many (fetchType = FetchType.EAGER,select = "com.mypro.mapper.EmpMapper.queryByDeptno"))
    })
    public List<Dept> queryAll();
    @Select("select *from dept where deptno = #{deptno}")
    @ResultMap(value = "deptMap")
    public Dept queryByPrimaryKey(Integer deptno);
}
